package com.iplant.pdm.service.po.bms;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.basic.service.basicenum.bfc.FMCShiftType;
import com.iplant.basic.service.basicenum.bms.BMSFunctionType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


/**
 * 班组管理范围
 *
 * @author YouWang·Peng
 * 2023-7-14 22:05:20
 */
@DBBasePO(TableName = "bms_classrange", CheckName = {"ClassInfoID,StationID,ProductTypeID,ShiftType"},
        Schemas = DBSchemas.PDM, Code = false, Name = false, Active = false)
public class BMSClassRange extends BasePO implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 班组信息ID
     */
    @DBCondition
    @DBField(CheckValue = true)
    public int ClassInfoID = 0;

    /**
     * 班组ID（来源于部门）
     */
    @DBCondition
    @DBField(CheckValue = true)
    public int DepartmentID = 0;

    /**
     * 班组名称（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "Name", tableName = "bms_department", tableAsName = "t1", Schemas = DBSchemas.Basic,
            MainTableField = "DepartmentID")
    public String DepartmentName = "";

    /**
     * 班组编码（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "Code", tableName = "bms_department", tableAsName = "t1", Schemas = DBSchemas.Basic,
            MainTableField = "DepartmentID")
    public String DepartmentCode = "";

    /**
     * 班组职能
     */
    @DBJoin(name = "FunctionType", tableName = "bms_classinfo", tableAsName = "t2", Schemas = DBSchemas.Basic,
            MainTableField = "ClassInfoID")
    public int FunctionType = 0;

    /**
     * 班组职能（翻译）
     */
    public String FunctionTypeName = "";

    /**
     * 产品类型ID
     */
    @DBCondition
    @DBField
    public int ProductTypeID = 0;
    /**
     * 产品类型名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_producttype", tableAsName = "p1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductTypeID")
    public String ProductTypeName = "";
    /**
     * 产品类型编码
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "fpc_producttype", tableAsName = "p1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductTypeID")
    public String ProductTypeCode = "";

    /**
     * 工位ID
     */
    @DBField(CheckValue = true)
    @DBCondition
    public int StationID = 0;
    /**
     * 工位名称
     */
    @DBJoin(name = "Name", tableName = "fmc_station", tableAsName = "t7", Schemas = DBSchemas.Basic,
            MainTableField = "StationID")
    public String StationName = "";
    /**
     * 工位编码
     */
    @DBJoin(name = "Code", tableName = "fmc_station", tableAsName = "t7", Schemas = DBSchemas.Basic,
            MainTableField = "StationID")
    public String StationCode = "";

    /**
     * 设备状态
     */
    @DBCondition
    @DBJoin(name = "Active", tableName = "fmc_station", tableAsName = "t7", Schemas = DBSchemas.Basic,
            MainTableField = "StationID")
    public int StationActive = 0;



    /**
     * 工区ID
     */
    @DBCondition
    @DBJoin(name = "WorkAreaID", tableName = "fmc_station", tableAsName = "t7", Schemas = DBSchemas.Basic,
            MainTableField = "StationID")
    public int WorkAreaID = 0;
    /**
     * 工区名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "t5", Schemas = DBSchemas.Basic, JoinIndex = 2
            , ConditionalJoin = "t7.WorkAreaID=t5.ID")
    public String WorkAreaName = "";

    /**
     * 工区编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "t5", Schemas = DBSchemas.Basic, JoinIndex = 2,
            ConditionalJoin = "t7.WorkAreaID=t5.ID")
    public String WorkAreaCode = "";

    /**
     * 车间ID
     */
    @DBCondition
    @DBJoin(name = "WorkShopID", tableName = "fmc_workarea", tableAsName = "t5", Schemas = DBSchemas.Basic, JoinIndex = 2,
            ConditionalJoin = "t7.WorkAreaID=t5.ID")
    public int WorkShopID = 0;
    /**
     * 车间名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "t4", Schemas = DBSchemas.Basic, JoinIndex = 3,
            ConditionalJoin = "t5.WorkshopID=t4.ID")
    public String WorkShopName = "";
    /**
     * 车间编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "t4", Schemas = DBSchemas.Basic, JoinIndex = 3,
            ConditionalJoin = "t5.WorkShopID=t4.ID")
    public String WorkShopCode = "";


    @DBJoin(name = "Name", tableName = "fmc_factory", tableAsName = "f1", Schemas = DBSchemas.Basic, JoinIndex = 4,
            ConditionalJoin = "t4.FactoryID=f1.ID")
    public String FactoryName = "";

    @DBJoin(name = "Code", tableName = "fmc_factory", tableAsName = "f1", Schemas = DBSchemas.Basic, JoinIndex = 4,
            ConditionalJoin = "t4.FactoryID=f1.ID")
    public String FactoryCode = "";

    /**
     * 班次
     */
    @DBCondition
    @DBField
    public int ShiftType = 0;
    /**
     * 班次名称
     */
    public String ShiftTypeName = "";


    /**
     * 责任人
     */
    @DBField
    public List<Integer> PersonIDList = new ArrayList<>();

    @DBJoinMulti(Name = "Name", TableName = "mbs_user", MainTableField = "PersonIDList")
    public String PersonName = "";


    public BMSClassRange() {
        super();
    }


    @JsonProperty("ClassInfoID")
    public int getClassInfoID() {
        return ClassInfoID;
    }

    public void setClassInfoID(int classInfoID) {
        ClassInfoID = classInfoID;
    }

    @JsonProperty("DepartmentID")
    public int getDepartmentID() {
        return DepartmentID;
    }

    public void setDepartmentID(int departmentID) {
        DepartmentID = departmentID;
    }

    @JsonProperty("DepartmentName")
    public String getDepartmentName() {
        return DepartmentName;
    }

    public void setDepartmentName(String departmentName) {
        DepartmentName = departmentName;
    }

    @JsonProperty("DepartmentCode")
    public String getDepartmentCode() {
        return DepartmentCode;
    }

    public void setDepartmentCode(String departmentCode) {
        DepartmentCode = departmentCode;
    }

    @JsonProperty("FunctionType")
    public int getFunctionType() {
        return FunctionType;
    }

    public void setFunctionType(int functionType) {
        FunctionType = functionType;
    }

    @JsonProperty("FunctionTypeName")
    public String getFunctionTypeName() {
        FunctionTypeName = BMSFunctionType.getEnumType(FunctionType).getLabel();
        return FunctionTypeName;
    }

    public void setFunctionTypeName(String functionTypeName) {
        FunctionTypeName = functionTypeName;
    }

    @JsonProperty("ProductTypeID")
    public int getProductTypeID() {
        return ProductTypeID;
    }

    public void setProductTypeID(int productTypeID) {
        ProductTypeID = productTypeID;
    }

    @JsonProperty("ProductTypeName")
    public String getProductTypeName() {
        return ProductTypeName;
    }

    public void setProductTypeName(String productTypeName) {
        ProductTypeName = productTypeName;
    }

    @JsonProperty("ProductTypeCode")
    public String getProductTypeCode() {
        return ProductTypeCode;
    }

    public void setProductTypeCode(String ProductTypeCode) {
        this.ProductTypeCode = ProductTypeCode;
    }

    @JsonProperty("StationID")
    public int getStationID() {
        return StationID;
    }

    public void setStationID(int stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("StationActive")
    public int getStationActive() {
        return StationActive;
    }

    public void setStationActive(int stationActive) {
        StationActive = stationActive;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("ShiftType")
    public int getShiftType() {
        return ShiftType;
    }

    public void setShiftType(int shiftType) {
        ShiftType = shiftType;
    }

    @JsonProperty("ShiftTypeName")
    public String getShiftTypeName() {
        ShiftTypeName = FMCShiftType.getEnumType(ShiftType).getLabel();
        return ShiftTypeName;
    }

    public void setShiftTypeName(String shiftTypeName) {
        ShiftTypeName = shiftTypeName;
    }

    @JsonProperty("PersonIDList")
    public List<Integer> getPersonIDList() {
        return PersonIDList;
    }

    public void setPersonIDList(List<Integer> personIDList) {
        PersonIDList = personIDList;
    }
    @JsonProperty("PersonName")
    public String getPersonName() {
        return PersonName;
    }

    public void setPersonName(String personName) {
        PersonName = personName;
    }
}
